#include "grayscalefilter.h"

GrayscaleFilter::GrayscaleFilter()
{
}

void GrayscaleFilter::filter(QImage* image)
{
    for(int y = 0; y < image->height(); y++) {
        for(int x = 0; x < image->width(); x++) {
            int rgb = image->pixel(x, y);

            int red = qRed(rgb);
            int green = qGreen(rgb);
            int blue = qBlue(rgb);

            int gray = ( 299*red + 587*green + 114*blue ) /1000;
            image->setPixel(x, y, qRgb(gray, gray, gray));
        }
    }
}

